package com.droid.lib.controls.demo.view;

import android.animation.Animator;
import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.daimajia.androidanimations.library.Techniques;
import com.daimajia.androidanimations.library.YoYo;
import com.droid.lib.controls.chart.renderer.FunnelData;
import com.droid.lib.controls.demo.R;
import com.droid.lib.controls.demo.widget.FunnelChartView;

import java.util.ArrayList;
import java.util.List;

import static com.droid.lib.controls.chart.renderer.XEnum.FunnelType.symmetry;

/**
 * 对称
 */

public class SymmetryFragment extends Fragment {
    private FunnelChartView mFunnelChartView;
    private List<FunnelData> mOriginalData;
    private List<FunnelData>surData;
    public SymmetryFragment() {
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_funnel, null);
        mFunnelChartView = (FunnelChartView) view.findViewById(R.id.fcu);

        mFunnelChartView.getmChart().setTitle("招聘数据分析");
        mFunnelChartView.getmChart().getToolTip().setCurrentView(mFunnelChartView);
        mOriginalData = new ArrayList<>();
        mOriginalData.add(new FunnelData("预计简历数量","简历数量", 100, Color.parseColor("#f8c276")));
        mOriginalData.add(new FunnelData("预计简历筛选","简历筛选", 95, Color.parseColor("#898fd4")));
        mOriginalData.add(new FunnelData("预计初试人数","初试人数", 80, Color.parseColor("#7fd6fe")));
        mOriginalData.add(new FunnelData("预计复试人数","复试人数", 60, Color.parseColor("#94cd67")));
        mOriginalData.add(new FunnelData("预计录用人数","录用人数", 30, Color.parseColor("#f17f66")));
        mOriginalData.add(new FunnelData("预计入职人数","入职人数", 10, Color.YELLOW,156));


        surData = new ArrayList<>();
        surData.add(new FunnelData("实际简历数量","简历数量", 90, Color.parseColor("#f8c276")));
        surData.add(new FunnelData("实际简历筛选","简历筛选", 80, Color.parseColor("#898fd4")));
        surData.add(new FunnelData("实际初试人数","初试人数", 50, Color.parseColor("#7fd6fe")));
        surData.add(new FunnelData("实际复试人数","复试人数", 30, Color.parseColor("#94cd67")));
        surData.add(new FunnelData("实际录用人数","录用人数", 10, Color.parseColor("#f17f66")));
        surData.add(new FunnelData("实际入职人数","入职人数", 5, Color.YELLOW,156));

        mFunnelChartView.setShowAnimation(false);
        mFunnelChartView.getmChart().setmFunType(symmetry);
        mFunnelChartView.setmOriginalData(mOriginalData);
        mFunnelChartView.setmContrastData(surData);
//        if (rope != null) {
//            rope.stop(true);
//        }
//        rope = YoYo.with(Techniques.FadeIn)
//                .duration(2000)
////                .repeat(YoYo.INFINITE)
//                .repeat(0)
////                .pivot(YoYo.CENTER_PIVOT, YoYo.CENTER_PIVOT)
////                .interpolate(new AccelerateDecelerateInterpolator())
//                .withListener(new Animator.AnimatorListener() {
//                    @Override
//                    public void onAnimationStart(Animator animation) {
//
//                    }
//
//                    @Override
//                    public void onAnimationEnd(Animator animation) {
//                    }
//
//                    @Override
//                    public void onAnimationCancel(Animator animation) {
//                    }
//
//                    @Override
//                    public void onAnimationRepeat(Animator animation) {
//
//                    }
//                })
//                .playOn(mFunnelChartView);
        return view;
    }
}
